package com.beiming.libra.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.beiming.libra.common.Assert;
import com.beiming.libra.common.constants.ValidateMessage;
import com.beiming.libra.common.enums.DictTypeEnum;
import com.beiming.libra.common.enums.ErrorCode;
import com.beiming.libra.domain.Dict;
import com.beiming.libra.helper.Result;
import com.beiming.libra.service.DictService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * 
 * @author weibo
 *
 */
@RestController
@Api(value = "字典表信息", tags = "字典表信息")
@RequestMapping("/api/dict")
public class DictController {

  @Resource
  private DictService dictService;

  /**
   * 查询擅长领域信息
   */
  @ApiOperation(value = "查询擅长领域信息", notes = "查询擅长领域信息")
  @RequestMapping(value = "dispute", method = RequestMethod.GET)
  @ResponseBody
  public Result<List<Dict>> getDispute() {
    List<Dict> ls = dictService.selectByType(DictTypeEnum.DISPUTE.getCode());
    return Result.success(ls);
  }

  /**
   * 根据类型查询字典信息
   */
  @ApiOperation(value = "根据类型查询字典信息", notes = "根据类型查询字典信息")
  @RequestMapping(value = "type/{type}", method = RequestMethod.GET)
  @ResponseBody
  public Result<List<Dict>> getByType(@ApiParam(value = "字典类型(DISPUTE[纠纷类型])", required = true) @PathVariable DictTypeEnum type) {

    Assert.isNotNull(type, ErrorCode.DICT_TYPE_IS_EMPTY, ValidateMessage.DICT_TYPE_NOT_BLANK);

    List<Dict> ls = dictService.selectByType(type.getCode());
    return Result.success(ls);
  }

}
